﻿using System;
using FlashCards.Dto;

namespace FlashCards.SL.FlashCardCreator.Utils
{
    public class FlashcardSetValidator
    {
        public static bool Validate(FlashcardSet set)
        {
            if (string.IsNullOrEmpty(set.Name))
                return false;

            if (set.Category == null)
                return false;

            if (set.Flashcards.Count == 0)
                return false;

            foreach (var flashcard in set.Flashcards)
            {
                if (flashcard.Term.Type == null)
                    return false;

                if (flashcard.Term.Data == null || flashcard.Term.Data.Length == 0)
                    return false;

                if (flashcard.Definition.Type == null)
                    return false;

                if (flashcard.Definition.Data == null || flashcard.Term.Data.Length == 0)
                    return false;
            }

            return true;
        }
    }
}
